/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2019
 */

package net.dreamlu.db.po;


import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.format.annotation.DateTimeFormat;


import lombok.Data;
import lombok.extern.slf4j.Slf4j;
/**
 *
 * @author lambert.wang email:lambert.wang(a)crediteyes.com
 * @version 1.0
 * @since 1.0
 */
@Data
@Slf4j
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "t_resource")
public class Resource implements Serializable {
	private static final long	serialVersionUID	= 5454155825314635342L;
	//alias
	public static final String TABLE_ALIAS = "Resource";
	public static final String ALIAS_ID = "主键";
	public static final String ALIAS_NAME = "资源名称";
	public static final String ALIAS_PERMISSIONS = "资源的权限";
	public static final String ALIAS_URL = "资源路径";
	public static final String ALIAS_OPEN_MODE = "打开方式 ajax,iframe";
	public static final String ALIAS_DESCRIPTION = "资源介绍";
	public static final String ALIAS_ICON_CLS = "资源图标";
	public static final String ALIAS_PID = "父级资源id";
	public static final String ALIAS_SEQ = "排序";
	public static final String ALIAS_STATUS = "状态[0:失效,1:正常]";
	public static final String ALIAS_OPENED = "打开状态";
	public static final String ALIAS_RESOURCE_TYPE = "资源类别";
	public static final String ALIAS_CREATE_TIME = "创建时间";
	public static final String ALIAS_UPDATE_TIME = "更新时间";
	
	public static final String PROP_ID = "id";
	public static final String PROP_NAME = "name";
	public static final String PROP_PERMISSIONS = "permissions";
	public static final String PROP_URL = "url";
	public static final String PROP_OPEN_MODE = "openMode";
	public static final String PROP_DESCRIPTION = "description";
	public static final String PROP_ICON_CLS = "iconCls";
	public static final String PROP_PID = "pid";
	public static final String PROP_SEQ = "seq";
	public static final String PROP_STATUS = "status";
	public static final String PROP_OPENED = "opened";
	public static final String PROP_RESOURCE_TYPE = "resourceType";
	public static final String PROP_CREATE_TIME = "createTime";
	public static final String PROP_UPDATE_TIME = "updateTime";
	//columns START
    /**
     * 主键       db_column: id 
     */ 	
	@Id 
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", unique = true, nullable = false, insertable = true, updatable = true, length = 10)
	private java.lang.Integer id;
    /**
     * 资源名称       db_column: name 
     */ 	
	@Column(name = "name", unique = false, nullable = false, insertable = true, updatable = true, length = 64)
	private java.lang.String name;
    /**
     * 资源的权限       db_column: permissions 
     */ 	
	@Column(name = "permissions", unique = false, nullable = true, insertable = true, updatable = true, length = 32)
	private java.lang.String permissions;
    /**
     * 资源路径       db_column: url 
     */ 	
	@Column(name = "url", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	private java.lang.String url;
    /**
     * 打开方式 ajax,iframe       db_column: open_mode 
     */ 	
	@Column(name = "open_mode", unique = false, nullable = true, insertable = true, updatable = true, length = 32)
	private java.lang.String openMode;
    /**
     * 资源介绍       db_column: description 
     */ 	
	@Column(name = "description", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	private java.lang.String description;
    /**
     * 资源图标       db_column: icon_cls 
     */ 	
	@Column(name = "icon_cls", unique = false, nullable = true, insertable = true, updatable = true, length = 32)
	private java.lang.String iconCls;
    /**
     * 父级资源id       db_column: pid 
     */ 	
	@Column(name = "pid", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	private java.lang.Integer pid;
    /**
     * 排序       db_column: seq 
     */ 	
	@Column(name = "seq", unique = false, nullable = false, insertable = true, updatable = true, length = 3)
	private Integer seq;
    /**
     * 状态[0:失效,1:正常]       db_column: status 
     */ 	
	@Column(name = "status", unique = false, nullable = false, insertable = true, updatable = true, length = 3)
	private Integer status;
    /**
     * 打开状态       db_column: opened 
     */ 	
	@Column(name = "opened", unique = false, nullable = false, insertable = true, updatable = true, length = 0)
	private java.lang.Boolean opened;
    /**
     * 资源类别       db_column: resource_type 
     */ 	
	@Column(name = "resource_type", unique = false, nullable = false, insertable = true, updatable = true, length = 3)
	private Integer resourceType;
    /**
     * 创建时间       db_column: create_time 
     */ 	
	@CreatedDate				
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") 
	@Column(name = "create_time", unique = false, nullable = false, insertable = true, updatable = true, length = 19)
	private java.time.LocalDateTime createTime;
    /**
     * 更新时间       db_column: update_time 
     */ 	
	@LastModifiedDate				
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") 
	@Column(name = "update_time", unique = false, nullable = false, insertable = true, updatable = true, length = 19)
	private java.time.LocalDateTime updateTime;
	//columns END
	@Override
	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.JSON_STYLE)
			.append(PROP_ID,getId())
			.append(PROP_NAME,getName())
			.append(PROP_PERMISSIONS,getPermissions())
			.append(PROP_URL,getUrl())
			.append(PROP_OPEN_MODE,getOpenMode())
			.append(PROP_DESCRIPTION,getDescription())
			.append(PROP_ICON_CLS,getIconCls())
			.append(PROP_PID,getPid())
			.append(PROP_SEQ,getSeq())
			.append(PROP_STATUS,getStatus())
			.append(PROP_OPENED,getOpened())
			.append(PROP_RESOURCE_TYPE,getResourceType())
			.append(PROP_CREATE_TIME,getCreateTime())
			.append(PROP_UPDATE_TIME,getUpdateTime())
			.toString();
	}
	@Override
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Resource == false) return false;
		if(this == obj) return true;
		Resource other = (Resource)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.isEquals();
	}
	
}
